﻿<%@ Page Language="C#" MasterPageFile="~/Views/Shared/Sacnetug.Master" Inherits="System.Web.Mvc.ViewPage<SacNetUG.Models.LogOnModel>" %>

<asp:Content ID="loginTitle" ContentPlaceHolderID="TitleContent" runat="server">
    Log On
</asp:Content>
<asp:Content ID="loginContent" ContentPlaceHolderID="MainContent" runat="server">
    <p>
        Welcome, please log in using either Windows Live ID or OpenID.
    </p>
    <p>
        Why are we handling security this way? Please read <a href="/Account/WhyOpenId" title="Why Open Id?">this.</a>
    </p>
    <fieldset>
        Log on using Windows Live ID:
        <iframe id="WebAuthControl" name="WebAuthControl" 
        src="http://login.live.com/controls/WebAuth.htm?appid=<%=Html.AppId()%>&style=font-size%3A+10pt%3B+font-family%3A+verdana%3B+background%3A+FFFFFF%3B"
            width="80px" height="20px" marginwidth="0" marginheight="0" align="middle" frameborder="0"
            scrolling="no"></iframe>
    </fieldset>
    <% using (Html.BeginForm(new { Controller = "Account", Action = "OpenIdLogon" }))
       { %>
    <fieldset>
        <div class="containercontent">
            <div class="labelheaderblock">
                Log on using OpenID:</div>
            <input id="openid_identifier" name="openid_identifier" style="width:300px;" />
            <input id="btnOpenIdLogin" type="submit" value="Login" />
            <img id="imgOpenIdLoginProgress" src="<%= ResolveUrl("~/Content/loading_small.gif") %>"
                style="display: none" />
            <div id="divOpenIdIcons">
                <img src="<%= ResolveUrl("~/Content/openid-icon.png") %>" onclick="openIdUrl('openid'); // setSelectionRange($('#openid_identifier'), 0, 14);"
                    title="myopenid.com" class="hoverbutton" />
                <img src="<%= ResolveUrl("~/Content/google-icon.png") %>" onclick="openIdUrl('google')"
                    title="Google" class="hoverbutton" />
                <img src="<%= ResolveUrl("~/Content/yahoo-icon.png") %>" onclick="openIdUrl('yahoo')"
                    title="Yahoo" class="hoverbutton" />
            </div>
            <div>Instructions: Click the icon of the provider you are using.<br />If you are using OpenID replace &lt;Your Account&gt; with your username and click the login button. You will then be redirected to MyOpenID for authentication.<br /><br />Google and Yahoo users will be redirected upon clicking the provider icon.<br /><br />Follow the provider's instructions and you will be returned to the SacNetUg.org site.</div>
        </div>
    </fieldset>
    <% } %>
    <script type="text/javascript">
        function openIdUrl(site) {
            var value = "";
            var autoClick = false;

            if (site == "openid") {
                value = "<Your Account>.myopenid.com";
            }
            else if (site == "google") {
                value = "https://www.google.com/accounts/o8/id";
                autoClick = true;
            }
            else if (site == "yahoo") {
                value = "http://yahoo.com/"
                autoClick = true;
            }

            if (value) {
                var jText = $("#openid_identifier");
                jText.val(value).focus();
                if (autoClick)
                    $("#btnOpenIdLogin").trigger("click");
                else
                    $('#openid_identifier').selectRange(0, 14);
            }
        }

        $.fn.selectRange = function (start, end) {
            return this.each(function () {
                if (this.setSelectionRange) {
                    this.focus();
                    this.setSelectionRange(start, end);
                } else if (this.createTextRange) {
                    var range = this.createTextRange();
                    range.collapse(true);
                    range.moveEnd('character', end);
                    range.moveStart('character', start);
                    range.select();
                }
            });
        };
    </script>
</asp:Content>
